﻿using FluentNHibernate.Mapping;
using Core.Business.Domain.Entities;

namespace Core.Infra.Data.Maps {
    public class CategoriaMap : ClassMap<Categoria>{
        public CategoriaMap() {
            Table("tbl_Categoria");

            Id(x => x.Id);

            Map(x => x.Descricao)
                .Not
                .Nullable();
            
            DiscriminateSubClassesOnColumn<int>("IdTipoCategoria", 1);
        }
    }

    public class SubCategoriaMap : SubclassMap<SubCategoria> {
        public SubCategoriaMap() {
            References<Categoria>(x => x.Categoria, "IdCategoria")
                .Cascade.All()
                .Nullable();

            DiscriminatorValue(2);
        }                
    }
}
